#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;


int main()
{
    int a, h, b, k;
    cin >> a >> h >> b >> k;
    int _min = (h / b, k / a);
    h = h - _min * b;
    k = k - _min * a;
    //cout<<h<<":"<<k<<endl;
    int count = (a + b) * _min;
    if (h > 0 && k > 0)
    {
        h = h - b;
        k = k - a;
        count += (a + b);
    }
    if (h > 0)
        count += a * 10;
    else if (k > 0)
        count += b * 10;
    cout << count;
    //     int count1 = h/b+(h%b==0?0:1);
    //     int count2 = k/a+(k%a==0?0:1);
    //     int _min = min(h/b+(h%b==0?0:1),k/a+(k%a==0?0:1));
    //     //cout<<count1<<":"<<count2<<endl;
    //     if(count1==count2)
    //     {
    //         cout<<(a+b)*count1;
    //     }
    //     else if(count1<count2) 
    //     {
    //         cout<<(a+b)*count1+b*10;
    //     }
    //     else
    //     {
    //         cout<<(a+b)*count2+a*10;
    //     }

    return 0;
}

#include <iostream>
using namespace std;
#include <vector>
int main() {
    int n;
    cin >> n;
    vector<int> arr(n, 0);
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vector<int> dp(n, 0);
    dp[0] = arr[0];
    int ret = arr[0];
    for (int i = 1; i < n; i++)
    {
        dp[i] = max(arr[i], dp[i - 1] + arr[i]);
        ret = max(ret, dp[i]);
    }
    //cout<<dp[n-1];
    cout << ret;
    return 0;

}

#include <iostream>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    bool flag = true;
    for (int i = 0; i < n - 1; i++)
    {
        if (s[n - 1] != s[i])
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        cout << 0;
        return 0;
    }
    int left = 0, right = n - 1;
    int flag1 = true;
    while (left < right)
    {
        if (s[left] == s[right])
        {
            left++;
            right--;
        }
        else
        {
            flag1 = false;
            break;
        }
    }
    if (flag1)
    {
        cout << n - 1;
    }
    else
    {
        cout << n;
    }
    return  0;
}